package cn.lingyangwl.agile.msg.push.listener;

import cn.lingyangwl.agile.dynamic.config.core.event.ConfigDeleteEvent;
import cn.lingyangwl.agile.msg.push.core.channel.ChannelClientManager;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author shenguangyang
 */
@Slf4j
@RequiredArgsConstructor
@Component
public class PushClientConfigEventListener {
    @Resource
    private ChannelClientManager clientManager;

    @EventListener(ConfigDeleteEvent.class)
    public void delete(ConfigDeleteEvent event) {
        Object configKey = event.getSource();
        clientManager.deleteChannelClient(String.valueOf(configKey));
    }

}
